package com.cxb.apipassenger.service;


import com.cxb.apipassenger.remote.ServicePriceClient;
import com.cxb.internalcommon.dto.ResponseResult;
import com.cxb.internalcommon.request.ForecastPriceDTO;
import com.cxb.internalcommon.responese.ForecastPriceResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ForecastPriceService {

    //depLongitude,depLatitude,destLongitude,destLatitude

    @Autowired
    private ServicePriceClient servicePriceClient;
    public ResponseResult forecastPrice(String depLongitude,String depLatitude ,String destLongitude,
                                        String destLatitude,String cityCode,String vehicleType){

        log.info("出发地经度:"+depLongitude);
        log.info("出发地纬度:"+depLatitude);
        log.info("目的地经度:"+destLongitude);
        log.info("目的地纬度:"+destLatitude);

        log.info("调用计价服务");
        ForecastPriceDTO forecastPriceDTO = new ForecastPriceDTO();
        forecastPriceDTO.setDepLongitude(depLongitude);
        forecastPriceDTO.setDepLatitude(depLatitude);
        forecastPriceDTO.setDestLongitude(destLongitude);
        forecastPriceDTO.setDestLatitude(destLatitude);
        forecastPriceDTO.setVehicleType(vehicleType);
        forecastPriceDTO.setCityCode(cityCode);
        ResponseResult<ForecastPriceResponse> forecast = servicePriceClient.forecastPrice(forecastPriceDTO);
/*        ForecastPriceResponse data = forecast.getData();
        double price = data.getPrice();
        String fareType = data.getFareType();

        ForecastPriceResponse forecastPriceResponse = new ForecastPriceResponse();
        forecastPriceResponse.setPrice(price);
        forecastPriceResponse.setVehicleType(vehicleType);
        forecastPriceResponse.setCityCode(cityCode);*/
        return ResponseResult.success(forecast.getData());
    }

}
